Hanami (Ruby) on Ubuntu

Hanami is a modern Ruby web framework. I’m experimenting with it right now.

 

Ubuntu, compared to other linux distros, or to a mac, can often require different steps when getting started with a new tool. Here is the process I followed, which got me up and running in just a few moments of work.

 

Install RVM
Ruby Version Manager (RVM) is one of the easiest ways to handle Ruby versioning, stay up to date, and minimize frustration.

 

If you already have RVM, run rvm get stable to make sure you’re up to date. Then run rvm cleanup all to get rid of any cruff (not strictly necessary, just useful).

 

For Hanami, you’ll need to be using a modern version of Ruby, 2.3.1 or higher.
You can have RVM list the Ruby versions it’s aware of by typing rvm list known. From this list you can select the version you want and install that with rvm install; at time of writing the newest stable Ruby version was 2.4.0, so I ran rvm install ruby-2.4.0.
This should also set your newly installed version of Ruby as the one that is selected to be used, but if you want to change it manually, you can run rvm use ruby-2.4.0, etc.

 

Now we’re ready for Hanami itself. Simply install the Hanami gem by running gem install hanami.

 

You’ll also need to make sure you have your database of choice installed (sqlite, postgres, etc).
For my purposes, I ran sudo apt-get install sqlite-3 libsqlite-dev. Chances are, on Ubuntu, you can skip this step, as it will already be installed.

 

Create a new project with hanami’s new command, e.g:
hanami new myproject

The new command will create a directory of the name you specified for the project; move into that directory (cd, etc), and run a bundle install to make sure everything’s ready to go. This might take a few minutes.

 

You’re now ready! Run bundle exec hanami server to check out your new project being served at localhost:2300.

 

You can use Hanami’s getting started guide as a launching pad, or check out the numerous guides and resources for learning this framework.

 

Good luck, and have fun!